﻿using System;
using System.Collections.Generic;
using System.Web;
using com.eforceglobal.QuickSearch.Command.Contracts;
using com.eforceglobal.QuickSearch.Command.DTO;

namespace com.eforceglobal.QuickSearch.Plugin.Test
{
    public class MyFirstPlugin : ISearchCommand
    {
        public void InvokeCommand(string commandName, List<ParameterInfo> parameters, HttpContext context)
        {
            context.Response.Write("My first plugin is working fine!!! </br>");
            context.Response.Write("Command Name: " + commandName + "</br>");
            
            if (string.IsNullOrEmpty(parameters[0].Value))
                context.Response.Write("<font color='red'><b>Error :</b> Please provide email id !!!</font>");
            else
                context.Response.Write("<font color='green'>You can now implement mail sending feature to: <b>" + parameters[0].Value + "</b></font>");
            //Process.Start("www.google.com");
            context.Response.Write("<br/><br/><b>-- Some of your details -- </b></br>");
            context.Response.Write("Browser Name : " + context.Request.Browser.Browser + "</br>");
            context.Response.Write("Browser Version : " + context.Request.Browser.MajorVersion + "." + context.Request.Browser.MinorVersion + "</br>");
            context.Response.Write("Platform : " + context.Request.Browser.Platform + "</br>");
            context.Response.Write("Your User Name : " + context.Request.LogonUserIdentity.Name + "</br>");
            context.Response.Write("Your IP Address: " + context.Request.UserHostAddress + "</br>");
            context.Response.Write("Your Computer Name: " + System.Net.Dns.GetHostEntry(context.Request.UserHostAddress).HostName);
            //context.Response.Redirect("~/About.aspx?ID=" + parameters[0].Value);
            //context.RewritePath("~/About.aspx?ID=" + parameters[0].Value,true);
        }
    } 
}
